package com.etoak.car.controller;

import com.etoak.car.bean.Comment;
import com.etoak.car.bean.vo.CarMoneyResp;
import com.etoak.car.bean.vo.TuResp;
import com.etoak.car.bean.vo.UserMoneyResp;
import com.etoak.car.service.TuService;
import com.etoak.commons.enums.ETEnums;
import com.etoak.commons.response.ETResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("tu")
public class TuController {

    @Autowired
    private TuService tuService;

    @GetMapping("/getDayMoney")
    public ETResponse getDayMoney(){
        List<TuResp> comment = tuService.getDayMoney();
        ETResponse response = new ETResponse();
        response.setCode(ETEnums.SUCCESS.getCode());
        response.setMsg(ETEnums.SUCCESS.getMsg());
        response.setData(comment);
        return response;
    }

    @GetMapping("/getMonthMoney")
    public ETResponse getMonthMoney(){
        List<TuResp> comment = tuService.getMonthMoney();
        ETResponse response = new ETResponse();
        response.setCode(ETEnums.SUCCESS.getCode());
        response.setMsg(ETEnums.SUCCESS.getMsg());
        response.setData(comment);
        return response;
    }

    @GetMapping("/getYearMoney")
    public ETResponse getYearMoney(){
        List<TuResp> comment = tuService.getYearMoney();
        ETResponse response = new ETResponse();
        response.setCode(ETEnums.SUCCESS.getCode());
        response.setMsg(ETEnums.SUCCESS.getMsg());
        response.setData(comment);
        return response;
    }

    /**
     * 每个车的出租个数，和每个车的营业额
     * @return
     */
    @GetMapping("/getCarMoney")
    public ETResponse getCarMoney(){

        List<CarMoneyResp> carMoneyResp = tuService.getCarMoney();
        ETResponse response = new ETResponse();
        response.setCode(ETEnums.SUCCESS.getCode());
        response.setMsg(ETEnums.SUCCESS.getMsg());
        response.setData(carMoneyResp);
        return response;
    }

    @GetMapping("/getUserMoney")
    public ETResponse getUserMoney(){
        List<UserMoneyResp> userMoneyResps = tuService.getUserMoney();

        ETResponse response = new ETResponse();
        response.setCode(ETEnums.SUCCESS.getCode());
        response.setMsg(ETEnums.SUCCESS.getMsg());
        response.setData(userMoneyResps);
        return response;
    }
}
